| Conditions | 1 |
| Paths | 1 |
| Total Lines | 72 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /** |
||
| 13 | constructor (name, register) { |
||
| 14 | /** |
||
| 15 | * The command's name |
||
| 16 | * @type {string} |
||
| 17 | * @name Command#name |
||
| 18 | * @default null |
||
| 19 | */ |
||
| 20 | this.name = name |
||
| 21 | /** |
||
| 22 | * The command's name |
||
| 23 | * @type {string} |
||
| 24 | * @name Command#register |
||
| 25 | * @default null |
||
| 26 | */ |
||
| 27 | this.register = register |
||
| 28 | /** |
||
| 29 | * A regPattern, to match with the command suffixe |
||
| 30 | * @type {RegExp} |
||
| 31 | * @name Command#regPattern |
||
| 32 | * @default null |
||
| 33 | */ |
||
| 34 | this.regPattern = null |
||
| 35 | /** |
||
| 36 | * A patterncallback to match with middleware |
||
| 37 | * @type {patternCallback} |
||
| 38 | * @name Command#patternCallback |
||
| 39 | * @default null |
||
| 40 | */ |
||
| 41 | this.patternCallback = null |
||
| 42 | /** |
||
| 43 | * The perm(s) required to send a invalid permission fisher code |
||
| 44 | * @type {(string|string[])} |
||
| 45 | * @name Command#discordSpecialPerms |
||
| 46 | * @default ["SEND_MESSAGES"] |
||
| 47 | */ |
||
| 48 | this.discordSpecialPerms = ['SEND_MESSAGES'] |
||
| 49 | /** |
||
| 50 | * The perm(s) required to execute the command |
||
| 51 | * @type {(string|string[])} |
||
| 52 | * @name Command#discordPermRequired |
||
| 53 | * @default [] |
||
| 54 | */ |
||
| 55 | this.discordPermRequired = [] |
||
| 56 | /** |
||
| 57 | * The channel type(s) where the command can be executed |
||
| 58 | * @type {(string|string[])} |
||
| 59 | * @name Command#channelType |
||
| 60 | * @default [dm,"group","text"] |
||
| 61 | */ |
||
| 62 | this.channelType = ['dm', 'group', 'text'] |
||
| 63 | /** |
||
| 64 | * An object to store data for middlewares, or for commands |
||
| 65 | * @type {Object} |
||
| 66 | * @name Command#locales |
||
| 67 | * @default Object() |
||
| 68 | */ |
||
| 69 | this.locales = {} |
||
| 70 | /** |
||
| 71 | * An alias or an array of alias for the command |
||
| 72 | * @type {(string|string[])} |
||
| 73 | * @name Command#aliases |
||
| 74 | * @default null |
||
| 75 | */ |
||
| 76 | this.aliases = null |
||
| 77 | /** |
||
| 78 | * If true, a fisherPromiseCallback is passed to the execute function instead of a fisherCallback |
||
| 79 | * @type {boolean} |
||
| 80 | * @name Command#isPromise |
||
| 81 | * @default false |
||
| 82 | */ |
||
| 83 | this.isPromise = false |
||
| 84 | } |
||
| 85 | /** |
||
| 99 |